package cyou.breathe.yuque;


import cyou.breathe.constant.AsciiBanner;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @author: breathe
 * @createTime: 2025-07-08
 */
public class YuqueService {
    public static String inputFile = "yuque.txt";
    public static String outputDir = "D:/breathe-note/bagu";
    public static String imageOutputDir = "D:/breathe-note/bagu/photo/";
    public static void main(String[] args) {
        System.out.println(AsciiBanner.get());

        try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(inputFile)) {
            String line;
            assert inputStream != null;
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            while ((line = reader.readLine()) != null) {
                String[] parts = line.split(",", 2);
                String url = parts[0].trim();
                String cookie = parts.length > 1 ? parts[1].trim() : null;

                System.out.println("当前下载地址：" + url);
                System.out.println("当前cookie：" + (cookie != null ? cookie : "None"));

                YuqueDownloader downloader = new YuqueDownloader(cookie, outputDir);
                downloader.downloadBook(url);

            }
        } catch (IOException e) {
            System.err.println("读取输入文件失败: " + e.getMessage());
        }
    }
}

